<template>
  <div class="app-container home">
    <div class="container_top">
      <div class="container_title">医疗重点监测</div>
      <div class="container_subtitle">
        <span>考核范围：2023.01.01 - 2023.11.30</span><span>同期：2022.01.01 - 2022.11.30</span><span>更新时间：2023.12.01</span>
      </div>
    </div>

    <el-row :gutter="8">
      <el-col :xs="24" :sm="12" :md="12" :lg="12" class="my-ul">
        <TipCard title="医院手术数据情况" :details="surgeryDetails">
          <template #chart>
            <chart1 />
          </template>
        </TipCard>
      </el-col>
      <el-col :xs="24" :sm="12" :md="12" :lg="12" class="my-ul">
        <TipCard title="满意度监测" :details="satisfactionDetails">
          <template #chart>
            <chart2 />
          </template>
        </TipCard>
      </el-col>
    </el-row>
    <el-row :gutter="8">
      <el-col :xs="24" :sm="12" :md="12" :lg="12" class="my-ul">
        <TipCard title="医护比监测" :details="ratioDetails">
          <template #chart>
            <chart3 />
          </template>
        </TipCard>
      </el-col>
      <el-col :xs="24" :sm="12" :md="12" :lg="12" class="my-ul">
        <TipCard title="每百名卫生技术人员科研项目经费" :details="researchDetails">
          <template #chart>
            <chart4 />
          </template>
        </TipCard>
      </el-col>
    </el-row>
    <el-row :gutter="8">
      <el-col :xs="24" :sm="12" :md="8" :lg="6" v-for="(item, index) in cardList" :key="index" class="my-ul">
        <el-card shadow="never" :body-style="{ padding: '16px' }">
          <div class="card_title">
            {{ item.title }}
            <template v-if="item.renderHeader">
              <el-popover placement="bottom" trigger="click">
                <template #reference>
                  <a class="card_more" slot="reference">
                    <el-icon size="14" style="vertical-align: middle;"><Setting /></el-icon>
                    <span style="padding-left: 6px;vertical-align: middle">更多要点</span>
                  </a>
                </template>
                  <a v-for="(item, index) in item.headerList" :key="index" class="pop_btn" @click="check(item)">
                    <el-icon color="#333" size="14" style="vertical-align: middle"><Share /></el-icon>
                    <span style="padding-left: 12px;vertical-align: middle">{{ item.buttonName }}</span>
                  </a> 
              </el-popover>
            </template>
          </div>
          <div v-if="item.amplitude" class="card_num">
            <div class="card_n_title">本年度增幅</div>
            <div class="card_n_detail">{{ item.amplitude }}</div>
          </div>
          <div v-if="item.num" class="card_detail">
            <template v-if="isPositive(item.num) > 0">
              <div class="card_d_title">同比上升</div>
              <div class="card_d_detail" style="color: #019933">
                <span>{{ item.num }}</span><el-icon>
                  <CaretTop />
                </el-icon>
              </div>
            </template>
            <template v-else>
              <div class="card_d_title">同比下降</div>
              <div class="card_d_detail" style="color: #dd2100">
                <span>{{ formatPercentage(item.num) }}</span><el-icon>
                  <CaretBottom />
                </el-icon>
              </div>
            </template>
          </div>
          <div v-if="item.cardInfo" class="card_info">
            <div class="card_i" v-for="(item, index) in item.cardInfo" :key="index">
              <div class="card_i_title">{{ item.title }}</div>
              <div class="card_i_detail">{{ item.value }}</div>
            </div>
          </div>
          <div class="card_btn">
            <template v-if="item.renderFooter">
              <div class="card_btn_left">
                <el-button type="primary" plain size="small">{{ item.buttonName }}</el-button>
              </div>
              <div class="card_btn_right"></div>
            </template>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup name="Treatment">
import chart1 from "./components/chart1"
import chart2 from "./components/chart2"
import chart3 from "./components/chart3"
import chart4 from "./components/chart4"
import TipCard from "./components/tipCard"
const surgeryDetails = reactive([
  { title: '患者手术数', value: '580', icon: '', color: '' },
  { title: '患者手术占比', value: '4%', icon: 'CaretTop', color: '#019933' },
  { title: '微创手术数', value: '735', icon: '', color: '' },
  { title: '微创手术占比', value: '2%', icon: 'CaretTop', color: '#019933' },
  { title: '四级手术数', value: '1048', icon: '', color: '' },
  { title: '四级手术占比', value: '1%', icon: 'CaretBottom', color: '#dd2100' },
])
const satisfactionDetails = reactive([
  { title: '门诊患者满意度同比', value: '4%', icon: 'CaretBottom', color: '#dd2100' },
  { title: '住院患者满意度同比', value: '2%', icon: 'CaretBottom', color: '#dd2100' },
  { title: '医务人员满意度同比', value: '1%', icon: 'CaretBottom', color: '#dd2100' },
])
const ratioDetails = reactive([
  { title: '当前注册医生数', value: '24500' },
  { title: '当前注册医生数同比', value: '4%', icon: 'CaretTop', color: '#019933' },
  { title: '当前注册护士数', value: '36700' },
  { title: '当前注册护士数同比', value: '2%', icon: 'CaretTop', color: '#019933' },
])
const researchDetails = reactive([
  { title: '往年科研项目经费', value: '2807400', icon: '', color: '' },
  { title: '今年科研项目经费', value: '2648800', icon: '', color: '' },
  { title: '科研项目经费较往年', value: '2%', icon: 'CaretBottom', color: '#dd2100' },
])
const cardList = reactive([
  {
    title: '生并发症发率',
    num: '0.04%',
    cardInfo: [
      {
        title: '手术并发症患者发生例数',
        value: '4例'
      },
      {
        title: '出院患者手术人数',
        value: '100人'
      }
    ],
    renderFooter: true,
    buttonName: '情况说明'
  },
  {
    title: 'l类切口手术部位感染率',
    num: '0.05%',
    cardInfo: [
      {
        title: '手术并发症患者发生例数',
        value: '5人数'
      },
      {
        title: '手术台次数',
        value: '100台次'
      }
    ],
    renderFooter: true,
    buttonName: '情况说明'
  },
  {
    title: '单病种质量控制',
    num: '-5%',
    renderHeader: true,
    headerList: [
      { buttonName: '本省数据查看' }
    ],
    cardInfo: [
      {
        title: '病种例数',
        value: '5项'
      },
      {
        title: '住院日数',
        value: '6项'
      },
      {
        title: '次均费用',
        value: '6项'
      }
    ],
    renderFooter: true,
    buttonName: '改进措施'
  },
])

function isPositive(item) {
  return parseFloat(item.replace('%', ''))
}
function formatPercentage(item) {
  return item.replace('-', '')
}
function check() {
  console.log("本省数据查看")
}
</script>

<style lang="scss" scoped>
.app-container {
  padding: 16px 16px;
  clear: both;

  &.home {
    overflow-x: hidden;
  }

  .container_top {
    width: 100%;
    height: 48px;
    margin-top: 4px;
    margin-bottom: 12px;
    display: flex;

    .container_title {
      text-align: left;
      font-size: 18px;
      font-weight: 600;
      line-height: 48px;
      flex: 1;
      padding-left: 6px;
    }

    .container_subtitle {
      font-size: 14px;
      line-height: 48px;
      color: #555555;
      padding-right: 6px;

      span {
        padding-left: 24px;
      }
    }
  }

  .my-ul {
    margin-bottom: 8px;

    .card_title {
      font-size: 15px;
      font-weight: 600;
      height: 30px;
      margin-bottom: 18px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding-left: 14px;
      position: relative;

      &:before {
        content: "";
        position: absolute;
        width: 4px;
        height: 12px;
        background: #0783ff;
        left: 0;
        margin: auto;
      }
    }

    .card_detail {
      font-size: 14px;
      display: flex;
      align-items: center;

      .card_d_title {
        flex: 1;
        text-align: left;
        font-weight: 600;
      }

      .card_d_detail {
        flex: 1;
        font-size: 14px;
        font-weight: 600;
        display: flex;
        align-items: flex-start;
        justify-content: flex-end;
      }
    }

    .card_info {
      padding-top: 16px;
      min-height: 94px;

      .card_i {
        display: flex;
        align-items: center;
        font-size: 13px;
        line-height: 26px;

        .card_i_title {
          flex: 1;
          text-align: left;
        }

        .card_i_detail {
          flex: 1;
          text-align: right;
        }
      }
    }

    .card_num {
      font-size: 14px;
      display: flex;
      align-items: center;
      padding-bottom: 12px;

      .card_n_title {
        flex: 1;
        text-align: left;
      }

      .card_n_detail {
        flex: 1;
        text-align: right;
        font-size: 16px;
      }
    }

    .card_btn {
      display: flex;
      margin-top: 12px;
      border-top: 1px solid #e5e5e5;
      padding-top: 12px;
      min-height: 41px;

      .card_btn_left {
        flex: 1;
        text-align: left;
      }

      .card_btn_right {
        flex: 1;
        text-align: right;
      }
    }
  }
}

a.pop_btn {
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card_more {
  font-size: 13px;
  color: #555555;
  font-weight: 400;
}
</style>
